<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:80:"D:\fangcms\fangcms_city_add\public/../application/manage\view\role\editmenu.html";i:1491905476;}*/ ?>
<!--权限设置-->
<div class="pad_lr_10">
    <form id="info_form" action="<?php echo url('Role/setrule'); ?>" method="post">
        <div class="J_tablelist table_list" data-acturi="">
            <table width="100%" cellspacing="0" id="J_cate_tree">
                <tbody id="catelist">
                <?php echo $list; ?>
                </tbody>
                <input type="hidden" name="role_id" value="<?php echo $roleid; ?>" />
            </table>
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/plugins/listTable.js"></script>
<script>
    $(function(){
        $('.J_tablelist').listTable();
    });
    $('#info_form').ajaxForm({success:complate,dataType:'json'});
    function complate(result){
        if(result.status == 1){
            $.dialog.get(result.dialog).close();
            $.yingloujie.tip({content:result.msg});
            setTimeout(function(){window.location.reload();},1000);
        } else {
            $.yingloujie.tip({content:result.msg, icon:'alert'});
        }
    }
</script>
<script src="__PUBLIC__/js/plugins/jquery.treetable.js"></script>

<script>
    $(function(){
        //initialState:'expanded'
        $("#J_cate_tree").treeTable({indent:20,treeColumn:1});
        //选择
        $('.J_checkitem').live('click',function(){
            var parent = $(this).parent().parent();
            var pid    = parent.attr('id');
            var find   = "tr.child-of-"+pid;
            var child  = $(find);
            var checked = $(this).get(0).checked;
            child.each(function(){
                getChildMenu(child,checked);
            });
        });
    });
    function getChildMenu(o,c){
        o.each(function(){
            var pid = $(this).attr('id');
            var find   = "tr.child-of-"+pid;
            var child  = $(find);
            $(this).children().find('.J_checkitem').get(0).checked=c;
            if(child.length>0){
                getChildMenu(child,c);
            }
        });
    }
</script>
